<template>
    <div>
        <a-modal v-model="show" title="转派" @ok="handleOk" @cancel="show = false">
            <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 19 }">
                <a-form-item label="整改措施id ">
                    <a-input v-model="form.id" :disabled="true" />
                </a-form-item>
                <a-form-item label="转派目标人员">
                    <a-select v-model="form.operatorId" placeholder="选择转派目标人员" show-search>
                        <a-select-option :value="item.userId" v-for="(item, index) in userAllList" :key="index">
                            {{ item.userName }}
                        </a-select-option>
                    </a-select>
                </a-form-item>
            </a-form>
        </a-modal>
    </div>
</template>
<script>
import { message } from 'ant-design-vue';
import { postHiddenRedeploy } from "@/services"
export default {
    props: {
        // 全部用户列表
        userAllList: {
            default: () => { },
            type: Array,
        },
    },
    data() {
        return {
            // 是否显示弹框
            show: false,
            // 表单
            form: {
                id: '',
                userId: '',
            },
        }
    },
    methods: {
        /**
         * 打开弹框
         */
        open(data) {
            this.show = true // 打开弹框
            this.form = this.$options.data().form // 初始化
            if (data?.id) {
                this.form.id = data.id
            }
        },
        /**
         * 确认提交
         */
        async handleOk() {
            let { form } = this
            if (form.dangerRecordId == '') {
                return message.warning('未获取到Id')
            }
            let res = await postHiddenRedeploy(this.form)
            if (res.code == 0) {
                message.success('修改成功')
            } else {
                return message.warning(res?.msg)
            }
            this.show = false
            this.$emit('ok', 1);
        }
    },
}
</script>